package models

import (
	"fmt"
	"github.com/astaxie/beego/orm"
)

type Collect struct {
	Id        int64 `json:"id";orm:"column(id);pk;auto"`
	UserId    int64 `json:"userId"`
	ArticleId int64 `json:"articleId"`
}

func CollectArt(uid int64, aid int64) (err int) {
	o := orm.NewOrm()
	p := Collect{UserId: uid, ArticleId: aid}
	i, e := o.InsertOrUpdate(&p, "userId", "articleId")
	if e == nil {
		return SQL_SUCCESS
	} else {
		fmt.Println("collect_result: ", i, e)
		return SQL_UNKNOW
	}
}
func UnCollectArt(uid int64, aid int64) (err int) {
	o := orm.NewOrm()
	p := Collect{UserId: uid, ArticleId: aid}
	i, e := o.InsertOrUpdate(&p, "userId", "articleId")
	if e == nil {
		return SQL_SUCCESS
	} else {
		fmt.Println("collect_result: ", i, e)
		return SQL_UNKNOW
	}
}
